<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $main_uid 主账号id
 * @property int $uid 私域用户ID
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $status 0-未发送 1-已发送  2-发送失败  3-机器人暂停发送
 * @property string $room_id 目标群id
 * @property string $contact_id 客户id
 * @property int $room_status 0-不在群  1-在群
 * @property int $robot_id 拉群机器人id
 * @property int $invite_id 邀请id
 * @property int $sub_id 子任务id
 * @property string $date 日期
 * @property-read null|ChRobot $robot 
 * @property-read null|ChContact $contact 
 * @property-read null|ChRoom $room 
 */
class ChCrowdInviteLog extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_crowd_invite_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'main_uid', 'uid', 'created_at', 'updated_at', 'status', 'room_id', 'contact_id', 'room_status', 'robot_id', 'invite_id', 'sub_id', 'date'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'main_uid' => 'integer', 'uid' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'status' => 'integer', 'room_status' => 'integer', 'robot_id' => 'integer', 'invite_id' => 'integer', 'sub_id' => 'integer'];

    public function robot()
    {
        return $this -> hasOne(ChRobot::class,'id','robot_id');
    }

    public function contact()
    {
        return $this -> hasOne(ChContact::class,'user_id','contact_id');
    }

    public function room()
    {
        return $this -> hasOne(ChRoom::class,'room_wxid','room_id');
    }
}
